/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package mx.edu.itschapala.sistemas.septimo.vista;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import mx.edu.itschapala.sistemas.septimo.control.CleinteLnLista;
import mx.edu.itschapala.sistemas.septimo.control.ClienteLnLocal;
import mx.edu.itschapala.sistemas.septimo.control.ProductoLnLista;
import mx.edu.itschapala.sistemas.septimo.control.ProductoLnLocal;
import mx.edu.itschapala.sistemas.septimo.control.VentasLnLista;
import mx.edu.itschapala.sistemas.septimo.control.VentasLnLocal;
import mx.edu.itschapala.sistemas.septimo.vista.enumeracion.TipoVentana;

/**
 *
 * 
 */
public class MenuPrincipal extends javax.swing.JFrame {
    private JFrame ventana;
    private JFrame ventana2;
    private JFrame ventana3;
    /**
     * Creates new form MenuPrincipal
     */
    public MenuPrincipal() {
        try{
            UIManager.setLookAndFeel("com.jtattoo.plaf.mint.MintLookAndFeel");
            
        }catch (Exception e){
            e.printStackTrace();
        }
        initComponents();
        setLocationRelativeTo(null);
        setResizable(true);
        setTitle("Menu principal");
        
            ((JPanel)getContentPane()).setOpaque(false); 
      ImageIcon uno=new ImageIcon(this.getClass().getResource("/Image/fondo.jpg"));
      JLabel fondo= new JLabel(); 
      fondo.setIcon(uno); getLayeredPane().add(fondo,JLayeredPane.FRAME_CONTENT_LAYER); 
      fondo.setBounds(0,0,uno.getIconWidth(),uno.getIconHeight());

    
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        Listar = new javax.swing.JMenuItem();
        ListaCliente = new javax.swing.JMenuItem();
        ListaVentas = new javax.swing.JMenuItem();
        RegisCLIENTE = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        editarCliente = new javax.swing.JMenuItem();
        BuscarCliente = new javax.swing.JMenuItem();
        EliminarCliente = new javax.swing.JMenuItem();
        ListarClientes = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jMenu1.setText("Producto");

        Listar.setText("ListaProducto");
        Listar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ListarActionPerformed(evt);
            }
        });
        jMenu1.add(Listar);

        ListaCliente.setText("ListaClientes");
        ListaCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ListaClienteActionPerformed(evt);
            }
        });
        jMenu1.add(ListaCliente);

        ListaVentas.setText("ListaVentas");
        ListaVentas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ListaVentasActionPerformed(evt);
            }
        });
        jMenu1.add(ListaVentas);

        jMenuBar1.add(jMenu1);

        RegisCLIENTE.setText("Cliente");

        jMenuItem2.setText("Registrar");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        RegisCLIENTE.add(jMenuItem2);

        editarCliente.setText("editar");
        editarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editarClienteActionPerformed(evt);
            }
        });
        RegisCLIENTE.add(editarCliente);

        BuscarCliente.setText("buscar");
        RegisCLIENTE.add(BuscarCliente);

        EliminarCliente.setText("eliminar");
        RegisCLIENTE.add(EliminarCliente);

        ListarClientes.setText("Listar");
        ListarClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ListarClientesActionPerformed(evt);
            }
        });
        RegisCLIENTE.add(ListarClientes);

        jMenuBar1.add(RegisCLIENTE);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 641, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 304, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private  ProductoLnLocal productoControl = new ProductoLnLista();
    private ClienteLnLocal clienteControl = new CleinteLnLista();
    private VentasLnLocal ventascontrol= new VentasLnLista();
    
    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        
    }//GEN-LAST:event_formWindowOpened

    private void ListarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListarActionPerformed
       if(ventana ==null){
           ventana= new Table(productoControl);
       }
        
        
        new Table(productoControl).setVisible(true);
    }//GEN-LAST:event_ListarActionPerformed

    private void editarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editarClienteActionPerformed
        // TODO add your handling code here:
        new RegistroCliente(null, clienteControl, TipoVentana.VENTANA_MODIFICAR).setVisible(true);
    }//GEN-LAST:event_editarClienteActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
       new RegistroCliente(null,clienteControl,TipoVentana.VENTANA_REGISTRO).setVisible(true);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void ListaClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListaClienteActionPerformed
        // TODO add your handling code here:
          if(ventana2 ==null){
           ventana2= new TableCliente(clienteControl);
       }
        
        
        new TableCliente(clienteControl).setVisible(true);
                                       

    }//GEN-LAST:event_ListaClienteActionPerformed

    private void ListarClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListarClientesActionPerformed
        // TODO add your handling code here:
        if(ventana2 ==null){
           ventana2= new TableCliente(clienteControl);
       }
        
        
        new TableCliente(clienteControl).setVisible(true);
                                       
    }//GEN-LAST:event_ListarClientesActionPerformed

    private void ListaVentasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListaVentasActionPerformed
        // TODO add your handling code here:
        if(ventana3 ==null){
           ventana3= new TableVentas(ventascontrol);
       }
        
        
        new TableVentas(ventascontrol).setVisible(true);
    }//GEN-LAST:event_ListaVentasActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MenuPrincipal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem BuscarCliente;
    private javax.swing.JMenuItem EliminarCliente;
    private javax.swing.JMenuItem ListaCliente;
    private javax.swing.JMenuItem ListaVentas;
    private javax.swing.JMenuItem Listar;
    private javax.swing.JMenuItem ListarClientes;
    private javax.swing.JMenu RegisCLIENTE;
    private javax.swing.JMenuItem editarCliente;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem2;
    // End of variables declaration//GEN-END:variables
}
